package com.traffic.api.config;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
import com.gxhl.gdp.core.properties.ConfigurableConstants;

/**
 * 类描述: api属性文件加载
 * 
 */
public class ApiProperties extends ConfigurableConstants {

	public static String FLOW_HOST;
	public static  String REDIS_HOST;
	public static int REDIS_PORT;
	public static  String REDIS_PASSWORD;
    //万恒专用
	public static  String WANHENG_TOKEN;
	public static  String WANHENG_KEY;
	public static  String WANHENG_SECURITY;
	public static  String WANHENG_CALLBACK_URL;
	//点博专用
	public static  String DIANBO_CTMID;
	public static  String DIANBO_KEY;

	static {
		  try { 
			    Properties prop = new Properties();    
			    InputStream in ;
				File file = new File("/data/wwwroot/conf/api.properties");  //线上环境  
				if (file.exists()) {
					in =new BufferedInputStream(new FileInputStream(file));
				}else {
					in=ApiProperties.class.getClassLoader().getResourceAsStream("api.properties"); //本地环境
				}
				prop.load(in); // /加载属性列表
				FLOW_HOST = prop.getProperty("traffic.host");
				REDIS_HOST = prop.getProperty("redis.host");
				REDIS_PORT = Integer.valueOf(prop.getProperty("redis.port"));
				REDIS_PASSWORD = prop.getProperty("redis.password");
			

				WANHENG_TOKEN = prop.getProperty("wanheng_token");
				WANHENG_KEY = prop.getProperty("wanheng_key");
				WANHENG_CALLBACK_URL = prop.getProperty("wanheng_callback_url");
				WANHENG_SECURITY = prop.getProperty("wanheng_security");

				DIANBO_CTMID = prop.getProperty("dianbo_ctmid");
				DIANBO_KEY = prop.getProperty("dianbo_key");
				in.close();
				 
			} catch (Exception e) {
				LOG.error("ApiProperties-配置文件出错："+e.getMessage());

			}
	}

}
